﻿
using AntDesign;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Web;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using ZFY.UMC.Model.Dto.User;
using ZFY.UMC.Model.Dto.UserClaim;

namespace ZFY.UMC.BlazorWebAssembly.Pages.User.UserManage
{
    public partial class UserManage
    {
        private static IEnumerable<int> PageItemsSource => new int[] { 5, 10, 20 };
        int _pageIndex = 1;
        int _total = 1;
        bool _loading = false;
        List<GetUserClaimListOutput> _userClamis = new List<GetUserClaimListOutput>();
    
        List<GetUserListOutput> _userList = new List<GetUserListOutput>() { new GetUserListOutput { 
            Claims = new List<Model.Dto.UserClaim.GetUserClaimListOutput>{ new Model.Dto.UserClaim.GetUserClaimListOutput { ClaimType="role",ClaimValue="管理员" } },
            CreationTime = DateTime.Now,
            Email = "798513242@qq.com",
            Id = 1,
            Name = "pengyue",
            NickName = "茫雾",
            PhoneNumber = "123456789"
        } };
      
        private int _claimPageIndex = 1;
        private int _claimPageSize = 5;
        private bool _visibleClaim;
        private List<GetUserClaimListOutput> _displayUserClamis = new List<GetUserClaimListOutput>();
        private int _pageSize = 5;
        int _claimTotal = 1;
        public string Display { get; set; }

        private void PageIndexChanged(PaginationEventArgs args)
        {
            
            //_navigation.NavigateTo($"mock?type={GetType().ToString().Replace($"{Assembly.GetExecutingAssembly().GetName().Name}.", "")}&page={args.Page}&size={args.PageSize}");
        }
        private void ClaimPageIndexChanged(PaginationEventArgs args)
        {
            Console.WriteLine(_userClamis.Count);
            _displayUserClamis = _userClamis.Skip((_claimPageIndex - 1) * _claimPageSize).Take(_claimPageSize).ToList();
        }
        private  void DisplyClaims(GetUserListOutput user)
        {
           
            _userClamis = _userList.FirstOrDefault(x => x.Id == 1).Claims.ToList();
            _displayUserClamis = _userClamis.Skip((_claimPageIndex - 1) * _claimPageSize).Take(_claimPageSize).ToList();
            _visibleClaim = true;
            
        }
        void HandleClaimOk(MouseEventArgs e)
        {
            _visibleClaim = false;
        }
        void HandleClaimCancle(MouseEventArgs e)
        {
            _visibleClaim = false;
        }

    }
}
